import re
from rest_framework import serializers

from api.models import User
from api.models.product import Porduct, PorductImage
from api.models.stock_record import StockPrice, StockRecord
from api.utils.backends import BucketOperation
from api.utils.enums import PriceType, MediaType
from api.utils.serializers import PaginationSerializer, PaginationResultSerializer


# 用户管理


class UpdateUserRequsetSerializers(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ["username", "mobile", "is_superuser", "password"]
        extra_kwargs = {"mobile": {"required": False}, "password": {"required": False}}


class DestroyUserQuerySerializers(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ["id"]


class CreateUserIdSerializers(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ["id"]


class CreateUserRequsetSerializers(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ["username", "mobile", "is_superuser", "password"]


class UserquerySerializers(serializers.ModelSerializer, PaginationSerializer):
    is_quer = serializers.BooleanField(help_text="是否是超级用户", default=False)

    class Meta:
        model = User
        fields = ["username", "mobile", "email", "is_quer", "page", "per_page", "limit"]

        extra_kwargs = {"mobile": {"required": False}}


class UserBodySerializers(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = "__all__"


class AdminUserBodySerializers(PaginationResultSerializer):
    data = UserBodySerializers(many=True)
